import QtQuick 1.1
import VPlay 1.0

ScriptComponent {

    objectName: "PlayerLogic"

    function inputActionPressed(action) {
        console.debug("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        if( action === "fire") {
            // x&y of this component are 0..
            console.debug("creating weapon at current position x", owningEntity.x, "y", owningEntity.y);

                // TODO: image is not accessible when created dynamically as it is an id! thus access it with owningEntity.image and alias it in Car.qml!
               // console.debug("image.imagePoints[0].x:", player.imagePoints[0].x, ", image.imagePoints[0].y:", image.imagePoints[0].y);
               // var imagePointInWorldCoordinates = mapToItem(level,player.x, player.y);
               // console.debug("imagePointInWorldCoordinates x", imagePointInWorldCoordinates.x, " y:", imagePointInWorldCoordinates.y);

            entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("Rocket.qml"), {"x": player.x, "y": player.y-30,"z": 5, "rotation": owningEntity.rotation-90});

        }
    }
}
